package org.hackystat.devcathlon.ui.page.login;

import java.util.List;

import org.apache.wicket.ResourceReference;
import org.apache.wicket.behavior.HeaderContributor;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.image.Image;
import org.hackystat.devcathlon.ui.DevcathlonSession;
import org.hackystat.devcathlon.ui.page.commons.panels.clock.ClockPanel;
import org.hackystat.devcathlon.ui.page.commons.panels.match.MatchCardsPanel;

/**
 * Provides a Home Page for signing in to Devcathlon. 
 * 
 * @author Philip Johnson, Scheller Sanchez, Phillip Lau
 */
public class LoginPage extends WebPage {
  
  /** Support serialization. */
  private static final long serialVersionUID = 1L;
  
  /**
   * Create the HomePage. 
   */
  public LoginPage() {
    add(HeaderContributor.forCss(org.hackystat.devcathlon.ui.Start.class, 
        "page/style/boilerplate/screen.css", "screen"));
    add(HeaderContributor.forCss(org.hackystat.devcathlon.ui.Start.class, 
        "page/style/boilerplate/print.css", "print"));
    add(new Label("title", "Devcathlon"));
    // Header logo
    add(new Image("logo",
        new ResourceReference(LoginPage.class, "devcathlon-header-logo.png")));
    // Login form
    add(new LoginForm("loginForm"));
    // Current clock
    add(new ClockPanel("clockPanel"));
    // Match listings
    List<String> matchNames = DevcathlonSession.get().getMatchesSession().getMatchNames();
    if (matchNames.isEmpty()) {
      add(new Label("matchCardsPanel", "Is there any life in this part of the webisphere?"));
    } 
    else {
      add(new MatchCardsPanel("matchCardsPanel", matchNames));
    }
  }
}
